{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}R:\WSV2\TBu_AKe\Bunching_NEW\descriptives_1502.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}15 Mar 2023, 15:52:45
{txt}
{com}. 
. cd // display in log file       
{res}R:\WSV2\TBu_AKe\Bunching_NEW
{txt}
{com}. 
.                 
.                 ** a) 
.                 **** Descriptives: data at bin level ****
.                 
. use spatial_4_sample_s, replace 
{txt}
{com}. 
. tabstat units eei kwh capacity if year == 2011 & eei_bin >= 59, stats(mean sd min max n) col(stat) long f(%9.3f) // R, 2011

{txt}{ralign 12:Variable} {...}
{c |}      Mean        SD       Min       Max         N
{hline 13}{c +}{hline 50}
{ralign 12:units} {...}
{c |}{...}
 {res}  563.504  1879.299     0.000 29661.754   992.000
{txt}{ralign 12:eei} {...}
{c |}{...}
 {res}   66.775    11.534    59.035   143.493   992.000
{txt}{ralign 12:kwh} {...}
{c |}{...}
 {res}  219.749    53.864   114.000   580.000   992.000
{txt}{ralign 12:capacity} {...}
{c |}{...}
 {res}    5.892     1.130     3.000    10.000   992.000
{txt}{hline 13}{c BT}{hline 50}

{com}. 
. tabstat units eei kwh capacity if year == 2011 & eei_bin < 59, stats(mean sd min max n) col(stat) long f(%9.3f) // U, 2014

{txt}{ralign 12:Variable} {...}
{c |}      Mean        SD       Min       Max         N
{hline 13}{c +}{hline 50}
{ralign 12:units} {...}
{c |}{...}
 {res}  829.500  2761.770     0.000 41459.369  2434.000
{txt}{ralign 12:eei} {...}
{c |}{...}
 {res}   51.425     5.994    32.020    58.994  2434.000
{txt}{ralign 12:kwh} {...}
{c |}{...}
 {res}  184.721    21.475    99.840   286.000  2434.000
{txt}{ralign 12:capacity} {...}
{c |}{...}
 {res}    6.623     1.100     3.000    12.000  2434.000
{txt}{hline 13}{c BT}{hline 50}

{com}. 
. tabstat units eei kwh capacity if year == 2014 & eei_bin < 59, stats(mean sd min max n) col(stat) long f(%9.3f) // U, 2014

{txt}{ralign 12:Variable} {...}
{c |}      Mean        SD       Min       Max         N
{hline 13}{c +}{hline 50}
{ralign 12:units} {...}
{c |}{...}
 {res}  570.083  2378.704     0.000 80317.187  7896.000
{txt}{ralign 12:eei} {...}
{c |}{...}
 {res}   48.207     7.359    20.809    58.994  7896.000
{txt}{ralign 12:kwh} {...}
{c |}{...}
 {res}  175.441    24.212    89.000   386.000  7896.000
{txt}{ralign 12:capacity} {...}
{c |}{...}
 {res}    6.756     1.187     3.000    15.000  7896.000
{txt}{hline 13}{c BT}{hline 50}

{com}. 
.                 ** b) 
.                 **** Bunching Segment ****
.                 
. tabstat units eei kwh capacity if year == 2011 & eei_bin > 57 & eei_bin < 59, stats(mean sd min max n) col(stat) long f(%9.3f) // B, 2011

{txt}{ralign 12:Variable} {...}
{c |}      Mean        SD       Min       Max         N
{hline 13}{c +}{hline 50}
{ralign 12:units} {...}
{c |}{...}
 {res}  995.640  2707.169     0.000 31567.330   412.000
{txt}{ralign 12:eei} {...}
{c |}{...}
 {res}   58.520     0.302    58.051    58.994   412.000
{txt}{ralign 12:kwh} {...}
{c |}{...}
 {res}  192.425    18.354   155.000   252.000   412.000
{txt}{ralign 12:capacity} {...}
{c |}{...}
 {res}    5.896     0.659     4.500     8.000   412.000
{txt}{hline 13}{c BT}{hline 50}

{com}. 
. tabstat units eei kwh capacity if year == 2014 & eei_bin > 57 & eei_bin < 59, stats(mean sd min max n) col(stat) long f(%9.3f) // B, 2014

{txt}{ralign 12:Variable} {...}
{c |}      Mean        SD       Min       Max         N
{hline 13}{c +}{hline 50}
{ralign 12:units} {...}
{c |}{...}
 {res}  526.582  2146.948     0.000 36541.206   971.000
{txt}{ralign 12:eei} {...}
{c |}{...}
 {res}   58.585     0.270    58.051    58.994   971.000
{txt}{ralign 12:kwh} {...}
{c |}{...}
 {res}  188.229    21.761   112.000   252.000   971.000
{txt}{ralign 12:capacity} {...}
{c |}{...}
 {res}    5.736     0.787     3.000     8.000   971.000
{txt}{hline 13}{c BT}{hline 50}

{com}. 
. 
.                 *** Disappearing cells ***
. codebook cell if year == 2011 & eei_bin > 59 & units > 1 // 686 

{txt}{hline}
{res}cell{right:(firstnm) cell}
{txt}{hline}

{col 19}Type: Numeric ({res}float{txt})

{col 18}Range: [{res}893{txt},{res}4388{txt}]{col 55}Units: {res}1
{col 10}{txt}Unique values: {res}83{col 51}{txt}Missing .: {res}0{txt}/{res}686

{txt}{col 19}Mean: {res}{ralign 7:1655.6}
{txt}{col 14}Std. dev.: {res}{ralign 7:428.314}

{txt}{col 12}Percentiles: {col 25}{ralign 7:10%}{ralign 10:25%}{ralign 10:50%}{ralign 10:75%}{ralign 10:90%}
{res}{col 25}{ralign 7:1269}{ralign 10:    1430}{ralign 10:    1645}{ralign 10:    1751}{ralign 10:    2073}
{txt}
{com}. 
. codebook cell if year == 2014 & eei_bin > 59 & units > 1 // 400 --> 286 disappeared 

{txt}{hline}
{res}cell{right:(firstnm) cell}
{txt}{hline}

{col 19}Type: Numeric ({res}float{txt})

{col 18}Range: [{res}893{txt},{res}3938{txt}]{col 55}Units: {res}1
{col 10}{txt}Unique values: {res}80{col 51}{txt}Missing .: {res}0{txt}/{res}400

{txt}{col 19}Mean: {res}{ralign 7:1612.45}
{txt}{col 14}Std. dev.: {res}{ralign 7:435.027}

{txt}{col 12}Percentiles: {col 25}{ralign 7:10%}{ralign 10:25%}{ralign 10:50%}{ralign 10:75%}{ralign 10:90%}
{res}{col 25}{ralign 7:1123.5}{ralign 10:    1341}{ralign 10:    1545}{ralign 10:    1751}{ralign 10:    2164}
{txt}
{com}. 
. codebook cell if year == 2011 & eei_bin < 59 & eei_bin > 57 & units > 1 // 686 

{txt}{hline}
{res}cell{right:(firstnm) cell}
{txt}{hline}

{col 19}Type: Numeric ({res}float{txt})

{col 18}Range: [{res}1075{txt},{res}1857{txt}]{col 55}Units: {res}1
{col 10}{txt}Unique values: {res}7{col 51}{txt}Missing .: {res}0{txt}/{res}372

{txt}{col 13}Tabulation: Freq.  Value
{col 20}{res}         6{col 32}1075
{col 20}        65{col 32}1177
{col 20}         9{col 32}1284
{col 20}       253{col 32}1395
{col 20}         7{col 32}1601
{col 20}        18{col 32}1626
{col 20}        14{col 32}1857
{txt}
{com}. 
. codebook cell if year == 2014 & eei_bin < 59 & eei_bin > 57 & units > 1 // 400 --> 286 disappeared 

{txt}{hline}
{res}cell{right:(firstnm) cell}
{txt}{hline}

{col 19}Type: Numeric ({res}float{txt})

{col 18}Range: [{res}797{txt},{res}1857{txt}]{col 55}Units: {res}1
{col 10}{txt}Unique values: {res}9{col 51}{txt}Missing .: {res}0{txt}/{res}745

{txt}{col 13}Tabulation: Freq.  Value
{col 20}{res}         1{col 32}797
{col 20}        38{col 32}978
{col 20}        25{col 32}1075
{col 20}       171{col 32}1177
{col 20}        92{col 32}1284
{col 20}       324{col 32}1395
{col 20}         4{col 32}1601
{col 20}        82{col 32}1626
{col 20}         8{col 32}1857
{txt}
{com}. 
. twoway kdensity units if year == 2014 & eei_bin > 59 & units < 1000 || kdensity units if year == 2011 & eei_bin > 59 & units < 1000 // see spike at zero and irregularity due to missing bins in 2014 curve
{res}{txt}
{com}. 
. 
.                 *** Clearance inventory ***
.                 
.                 * cell-level product count 
. gen restricted = 0              
{txt}
{com}. replace restricted = 1 if eei_bin > 59 & eei_bin != . 
{txt}(5,942 real changes made)

{com}. 
. by restricted year,     sort: egen sr=sum(units)
{txt}
{com}. 
. by year,        sort: egen st=sum(units)
{txt}
{com}. 
. gen rr = sr/st if restricted == 1
{txt}(50,273 missing values generated)

{com}. 
. tab rr if year == 2014

         {txt}rr {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
   .0239518 {c |}{res}        719      100.00      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        719      100.00
{txt}
{com}. 
. *log close 
. 
. clear 
{txt}
{com}. 
. 
.                 ** c) 
.         *cd "C:\Users\hy65byfe\Desktop\smerge_0712\First stage Regressions"
. 
.         *cd "R:\WSV2\TBu_AKe\Product Ban\Stata\Bunching_Empirics\Status Dec 7 2020"
. 
. cd "$store"
{res}R:\WSV2\TBu_AKe\Bunching_NEW
{txt}
{com}. 
. capture mkdir Graphs
{txt}
{com}. global graphs "${c -(}store{c )-}\Graphs"
{txt}
{com}. 
.         ** load data ** 
. use "R:\WSV2\TBu_AKe\Product Ban\Stata\Bunching_Empirics\WM_V10_precollapse_binbasis.dta"
{txt}
{com}.  
. gen kwh = ae // avoid confusion with E,e : yearly consumption as defined by regulation.  
{txt}(689,472 missing values generated)

{com}. 
.  ** basic descriptives
. summ kwh capacity, detail 

                             {txt}kwh
{hline 61}
      Percentiles      Smallest
 1%    {res}      116             58
{txt} 5%    {res}      137             58
{txt}10%    {res}      148             58       {txt}Obs         {res}    500,101
{txt}25%    {res}      163             58       {txt}Sum of wgt. {res}    500,101

{txt}50%    {res}      174                      {txt}Mean          {res} 180.0771
                        {txt}Largest       Std. dev.     {res} 34.29484
{txt}75%    {res}      194           1224
{txt}90%    {res}      216           1224       {txt}Variance      {res} 1176.136
{txt}95%    {res}      238           1224       {txt}Skewness      {res} 3.843271
{txt}99%    {res}      299           1224       {txt}Kurtosis      {res} 74.38685

                          {txt}capacity
{hline 61}
      Percentiles      Smallest
 1%    {res}      3.5            1.5
{txt} 5%    {res}      4.5            1.5
{txt}10%    {res}        5            1.5       {txt}Obs         {res}  1,186,121
{txt}25%    {res}        5            1.5       {txt}Sum of wgt. {res}  1,186,121

{txt}50%    {res}        6                      {txt}Mean          {res} 6.022605
                        {txt}Largest       Std. dev.     {res} 1.263033
{txt}75%    {res}        7             16
{txt}90%    {res}        8             16       {txt}Variance      {res} 1.595253
{txt}95%    {res}        8             16       {txt}Skewness      {res} .8587801
{txt}99%    {res}       10             16       {txt}Kurtosis      {res} 4.776902
{txt}
{com}. drop if kwh > 600 // after manual check against product menu. max: DAEWOO can be dropped, reduce to 600. 
{txt}(689,508 observations deleted)

{com}. sum kwh capacity, detail

                             {txt}kwh
{hline 61}
      Percentiles      Smallest
 1%    {res}      116             58
{txt} 5%    {res}      137             58
{txt}10%    {res}      148             58       {txt}Obs         {res}    500,065
{txt}25%    {res}      163             58       {txt}Sum of wgt. {res}    500,065

{txt}50%    {res}      174                      {txt}Mean          {res}  180.002
                        {txt}Largest       Std. dev.     {res} 33.13248
{txt}75%    {res}      194            580
{txt}90%    {res}      216            580       {txt}Variance      {res} 1097.761
{txt}95%    {res}      238            580       {txt}Skewness      {res} 2.017477
{txt}99%    {res}      299            580       {txt}Kurtosis      {res} 14.46489

                          {txt}capacity
{hline 61}
      Percentiles      Smallest
 1%    {res}        4              3
{txt} 5%    {res}        5              3
{txt}10%    {res}        5              3       {txt}Obs         {res}    500,065
{txt}25%    {res}        6              3       {txt}Sum of wgt. {res}    500,065

{txt}50%    {res}        7                      {txt}Mean          {res} 6.649232
                        {txt}Largest       Std. dev.     {res} 1.238976
{txt}75%    {res}        7             15
{txt}90%    {res}        8             15       {txt}Variance      {res} 1.535062
{txt}95%    {res}        9             15       {txt}Skewness      {res} .6214287
{txt}99%    {res}       10             15       {txt}Kurtosis      {res} 5.016268
{txt}
{com}.         ** range kwh: 58 to 580, spread grows in both directions over time 
.         ** range capacity: 3 to 15, right tail 'grows' over time. 
. sum eei, detail // starts at 13.5 

                             {txt}eei
{hline 61}
      Percentiles      Smallest
 1%    {res}  27.3181       13.56091
{txt} 5%    {res}  32.0318       13.56091
{txt}10%    {res} 38.91125       13.56091       {txt}Obs         {res}    500,065
{txt}25%    {res} 44.65089       13.56091       {txt}Sum of wgt. {res}    500,065

{txt}50%    {res} 50.64429                      {txt}Mean          {res}  50.3538
                        {txt}Largest       Std. dev.     {res} 10.42067
{txt}75%    {res} 57.55145       143.4933
{txt}90%    {res} 61.13275       143.4933       {txt}Variance      {res} 108.5903
{txt}95%    {res} 66.27136       143.4933       {txt}Skewness      {res} 1.076723
{txt}99%    {res} 76.03767       143.4933       {txt}Kurtosis      {res} 9.543992
{txt}
{com}. 
. gen units_pos = units
{txt}(169,431 missing values generated)

{com}. gen unit_weight = round(units_pos, 1)
{txt}(169,431 missing values generated)

{com}. replace unit_weight = 0 if units < 0 
{txt}(38 real changes made)

{com}. 
. **------- Figure 1: Bunch_Ban -------- **
. #delimit;
{txt}delimiter now ;
{com}. graph twoway (scatter ae capacity if ae < 1000 & eei_bin < 58, msymbol(smcircle_hollow) mcolor(dkgreen)) 
>                          (scatter ae capacity if ae < 1000 & eei_bin > 58, msymbol(smdiamond_hollow) mcolor(grey)) 
>                          (scatter ae capacity if ae < 1000 & inrange(eei_bin,57.5,58.5), msymbol(smdiamond_hollow) mcolor(red)), 
>                          legend(label(1 "EEI < 58") label(2 "EEI ≥ 59 ") label(3 "57.5 ≤ EEI < 59") row(1)) graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) xtitle("Capacity") ytitle("Energy Consumption")
>                          ylabel(0(100)600, labsize(small)) xlabel(2(2)16, labsize(small)) xscale(range(2 16));
{p 0 4 2}
{txt}(note:  named style
grey not found in class
color,  default attributes used)
{p_end}
{p 0 4 2}
{txt}(note:  named style
grey not found in class
color,  default attributes used)
{p_end}
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. cd "$graphs" 
{res}R:\WSV2\TBu_AKe\Bunching_NEW\Graphs
{txt}
{com}. graph save       FigD1_banned.gph, replace
{res}{txt}file {bf:FigD1_banned.gph} saved

{com}. graph export FigD1_banned.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD1_banned.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD1_banned.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD1_banned.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. **------- Figure 2: Capacity -------- **
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram capacity [fw=unit_weight] if year == 2011 & inrange(capacity,3.5,10) & inrange(capacity,3.5,10) & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(ebg) lcolor(black%70) lwidth(vthin) start(3.5) width(0.1)
> xtitle("Capacity (kg)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.1)0.4, labsize(small)) xlabel(3(1)10, labsize(small)) yscale(range(0 0.4))
> ;
{txt}(bin={res}65{txt}, start={res}3.5{txt}, width={res}.1{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_a11_trunc.gph, replace
{res}{txt}file {bf:FigD2_a11_trunc.gph} saved

{com}. graph export FigD2_a11_trunc.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_a11_trunc.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_a11_trunc.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_a11_trunc.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram capacity [fw=unit_weight] if year == 2014 & inrange(capacity,3.5,10)  & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(dkgreen) lcolor(black%70) lwidth(vthin) start(3.5) width(0.1)
> xtitle("Capacity (kg)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.1)0.4, labsize(small)) xlabel(3(1)10, labsize(small)) yscale(range(0 0.4))
> ;
{txt}(bin={res}65{txt}, start={res}3.5{txt}, width={res}.1{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_a14_trunc.gph, replace
{res}{txt}file {bf:FigD2_a14_trunc.gph} saved

{com}. graph export FigD2_a14_trunc.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_a14_trunc.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_a14_trunc.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_a14_trunc.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. 
. **------- Figure 3: Energy Consumption -------- **
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram kwh [fw=unit_weight] if year == 2011 & inrange(kwh,122,299) & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(ebg) lcolor(black%70) lwidth(vthin) start(122) width(3)
> xtitle("Energy Consumption (kWh/year)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.05)0.2, labsize(small)) xlabel(100(50)300, labsize(small)) yscale(range(0 0.2))
> ;
{txt}(bin={res}59{txt}, start={res}122{txt}, width={res}3{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_e11_trunc.gph, replace
{res}{txt}file {bf:FigD2_e11_trunc.gph} saved

{com}. graph export FigD2_e11_trunc.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_e11_trunc.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_e11_trunc.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_e11_trunc.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram kwh [fw=unit_weight] if year == 2014 & inrange(kwh,122,299) & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(dkgreen) lcolor(black%70) lwidth(vthin) start(120) width(3)
> xtitle("Energy Cpnsumption (kWh/year)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.05)0.2, labsize(small)) xlabel(100(50)300, labsize(small)) yscale(range(0 0.2))
> ;
{txt}(bin={res}60{txt}, start={res}120{txt}, width={res}3{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_e14_trunc.gph, replace
{res}{txt}file {bf:FigD2_e14_trunc.gph} saved

{com}. graph export FigD2_e14_trunc.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_e14_trunc.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_e14_trunc.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_e14_trunc.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. 
. **------- Unweighted: Capacity -------- **
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram capacity if year == 2011 & inrange(capacity,3.5,10) & inrange(capacity,3.5,10) & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(ebg) lcolor(black%70) lwidth(vthin) start(3.5) width(0.1)
> xtitle("Capacity (kg)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.1)0.4, labsize(small)) xlabel(3(1)10, labsize(small)) yscale(range(0 0.4))
> ;
{txt}(bin={res}65{txt}, start={res}3.5{txt}, width={res}.1{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_a11_nw.gph, replace
{res}{txt}file {bf:FigD2_a11_nw.gph} saved

{com}. graph export FigD2_a11_nw.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_a11_nw.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_a11_nw.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_a11_nw.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram capacity if year == 2014 & inrange(capacity,3.5,10)  & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(dkgreen) lcolor(black%70) lwidth(vthin) start(3.5) width(0.1)
> xtitle("Capacity (kg)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.1)0.4, labsize(small)) xlabel(3(1)10, labsize(small)) yscale(range(0 0.4))
> ;
{txt}(bin={res}65{txt}, start={res}3.5{txt}, width={res}.1{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_a14_nw.gph, replace
{res}{txt}file {bf:FigD2_a14_nw.gph} saved

{com}. graph export FigD2_a14_nw.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_a14_nw.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_a14_nw.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_a14_nw.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. 
. **------- Unweighted: Energy Consumption -------- **
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram kwh if year == 2011 & inrange(kwh,122,299) & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(ebg) lcolor(black%70) lwidth(vthin) start(122) width(3)
> xtitle("Energy Consumption (kWh/year)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.05)0.2, labsize(small)) xlabel(100(50)300, labsize(small)) yscale(range(0 0.2))
> ;
{txt}(bin={res}59{txt}, start={res}122{txt}, width={res}3{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_e11_nw.gph, replace
{res}{txt}file {bf:FigD2_e11_nw.gph} saved

{com}. graph export FigD2_e11_nw.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_e11_nw.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_e11_nw.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_e11_nw.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. #delimit;
{txt}delimiter now ;
{com}. histogram kwh if year == 2014 & inrange(kwh,122,299) & eei_bin < 100 & eei_bin > 50
> , fraction fcolor(dkgreen) lcolor(black%70) lwidth(vthin) start(120) width(3)
> xtitle("Energy Cpnsumption (kWh/year)") ytitle("Percent of Sales") graphregion(color(white)) plotregion(lcolor(black))
>                          title("", color(black) size(medsmall)) 
>                          ylabel(0(0.05)0.2, labsize(small)) xlabel(100(50)300, labsize(small)) yscale(range(0 0.2))
> ;
{txt}(bin={res}60{txt}, start={res}120{txt}, width={res}3{txt})
{res}{txt}
{com}.  #delimit cr
{txt}delimiter now cr
{com}. 
. graph save       FigD2_e14_nw.gph, replace
{res}{txt}file {bf:FigD2_e14_nw.gph} saved

{com}. graph export FigD2_e14_nw.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigD2_e14_nw.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigD2_e14_nw.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigD2_e14_nw.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. preserve
{txt}
{com}. sort year eei_bin country month
{txt}
{com}. #delimit ;
{txt}delimiter now ;
{com}. collapse (firstnm) id_cn capacity ae ae2 eei eei2 energy_label_eu energy_efficiency class_A wm_labelbin revs_min_2 type_wm_2 bunch* banned*
>                  (max) tot_all* sum_countries sum_units* newid exitid (min) product_count* units_bin units_country_bin*
>                  (sum) n_all* flag3 flag4 units_clean units
>                  (mean) price price_all price_eur lifespan* age_country age_xc age_country_reverse, 
>                  by(eei_bin country year) ;
{res}{txt}
{com}. #delimit cr     
{txt}delimiter now cr
{com}. gen logunits = ln(units)
{txt}(336 missing values generated)

{com}. rename ae ae_raw
{res}{txt}
{com}. rename ae2 ae 
{res}{txt}
{com}. rename eei eei_raw
{res}{txt}
{com}. rename eei2 eei  
{res}{txt}
{com}.         
. 
. tab eei_bin if eei  < 62        // check distribution   

    {txt}eei_bin {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       13.5 {c |}{res}         13        0.38        0.38
{txt}         16 {c |}{res}          1        0.03        0.41
{txt}       17.5 {c |}{res}          4        0.12        0.52
{txt}         18 {c |}{res}         13        0.38        0.90
{txt}         19 {c |}{res}          2        0.06        0.96
{txt}       20.5 {c |}{res}         12        0.35        1.30
{txt}         22 {c |}{res}         30        0.87        2.17
{txt}       22.5 {c |}{res}         28        0.81        2.99
{txt}         25 {c |}{res}          6        0.17        3.16
{txt}         26 {c |}{res}          5        0.14        3.30
{txt}       26.5 {c |}{res}         20        0.58        3.88
{txt}         27 {c |}{res}         26        0.75        4.64
{txt}       27.5 {c |}{res}         16        0.46        5.10
{txt}         28 {c |}{res}          8        0.23        5.33
{txt}       28.5 {c |}{res}          9        0.26        5.59
{txt}         29 {c |}{res}          5        0.14        5.74
{txt}       29.5 {c |}{res}         38        1.10        6.84
{txt}       30.5 {c |}{res}          4        0.12        6.96
{txt}       31.5 {c |}{res}         38        1.10        8.06
{txt}         32 {c |}{res}         46        1.33        9.39
{txt}       32.5 {c |}{res}         28        0.81       10.20
{txt}         33 {c |}{res}         21        0.61       10.81
{txt}       33.5 {c |}{res}         13        0.38       11.19
{txt}       34.5 {c |}{res}          8        0.23       11.42
{txt}         35 {c |}{res}         33        0.96       12.38
{txt}       35.5 {c |}{res}         41        1.19       13.57
{txt}         36 {c |}{res}         49        1.42       14.99
{txt}       36.5 {c |}{res}         42        1.22       16.20
{txt}         37 {c |}{res}         30        0.87       17.07
{txt}       37.5 {c |}{res}         44        1.28       18.35
{txt}         38 {c |}{res}         48        1.39       19.74
{txt}       38.5 {c |}{res}         42        1.22       20.96
{txt}         39 {c |}{res}         41        1.19       22.14
{txt}       39.5 {c |}{res}         46        1.33       23.48
{txt}         40 {c |}{res}         37        1.07       24.55
{txt}       40.5 {c |}{res}         40        1.16       25.71
{txt}         41 {c |}{res}         41        1.19       26.90
{txt}       41.5 {c |}{res}         48        1.39       28.29
{txt}         42 {c |}{res}         62        1.80       30.09
{txt}       42.5 {c |}{res}         56        1.62       31.71
{txt}         43 {c |}{res}         64        1.86       33.57
{txt}       43.5 {c |}{res}         45        1.30       34.87
{txt}         44 {c |}{res}         63        1.83       36.70
{txt}       44.5 {c |}{res}         57        1.65       38.35
{txt}         45 {c |}{res}         52        1.51       39.86
{txt}       45.5 {c |}{res}         72        2.09       41.94
{txt}         46 {c |}{res}         39        1.13       43.07
{txt}       46.5 {c |}{res}         38        1.10       44.17
{txt}         47 {c |}{res}         45        1.30       45.48
{txt}       47.5 {c |}{res}         47        1.36       46.84
{txt}         48 {c |}{res}         54        1.57       48.41
{txt}       48.5 {c |}{res}         62        1.80       50.20
{txt}         49 {c |}{res}         61        1.77       51.97
{txt}       49.5 {c |}{res}         51        1.48       53.45
{txt}         50 {c |}{res}         55        1.59       55.04
{txt}       50.5 {c |}{res}         66        1.91       56.96
{txt}         51 {c |}{res}         88        2.55       59.51
{txt}       51.5 {c |}{res}         85        2.46       61.97
{txt}         52 {c |}{res}         88        2.55       64.52
{txt}       52.5 {c |}{res}         35        1.01       65.54
{txt}         53 {c |}{res}         54        1.57       67.10
{txt}       53.5 {c |}{res}         74        2.14       69.25
{txt}         54 {c |}{res}         41        1.19       70.43
{txt}       54.5 {c |}{res}         73        2.12       72.55
{txt}         55 {c |}{res}         76        2.20       74.75
{txt}       55.5 {c |}{res}         57        1.65       76.41
{txt}         56 {c |}{res}         65        1.88       78.29
{txt}       56.5 {c |}{res}         72        2.09       80.38
{txt}         57 {c |}{res}         77        2.23       82.61
{txt}       57.5 {c |}{res}         81        2.35       84.96
{txt}         58 {c |}{res}         78        2.26       87.22
{txt}       58.5 {c |}{res}         66        1.91       89.13
{txt}         59 {c |}{res}         86        2.49       91.62
{txt}       59.5 {c |}{res}         63        1.83       93.45
{txt}         60 {c |}{res}         45        1.30       94.75
{txt}       60.5 {c |}{res}         44        1.28       96.03
{txt}         61 {c |}{res}         98        2.84       98.87
{txt}       61.5 {c |}{res}         39        1.13      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}      3,450      100.00
{txt}
{com}. 
. replace banned = 0 if eei_bin < 59
{txt}(0 real changes made)

{com}. replace banned = 1 if eei_bin >= 59
{txt}(0 real changes made)

{com}. 
. gen units_pos = units
{txt}
{com}. 
. gen unit_weight = round(units_pos, 1)
{txt}
{com}. replace unit_weight = 0 if eei_bin >= 59 & year > 2013 // exclude rest inventory 
{txt}(432 real changes made)

{com}. 
. replace product_count_bin = 0 if eei_bin >= 59 & year > 2013
{txt}(587 real changes made)

{com}. 
. 
. *******-----------------------------------------------***
. * create bunching graph *
. *******-----------------------------------------------***
. cd "$graphs"
{res}R:\WSV2\TBu_AKe\Bunching_NEW\Graphs
{txt}
{com}. 
. 
.         *** sales-weighted ***
.         
.                 ** 2011 ** 
. #delimit;
{txt}delimiter now ;
{com}. graph twoway histogram eei_bin if year == 2011 & eei_bin < 68 & eei_bin > 53 [fw=unit_weight], 
> start(53.5)width(0.4) fraction xline(58.7) fcolor(ebg) lcolor(black%70) lwidth(vthin) xtitle("") 
> ytitle("Percent of Sales") legend(off) graphregion(color(white)) plotregion(lcolor(black))
> ylabel(0(0.1)0.4, labsize(small)) xlabel(54(2)68, labsize(small)) yscale(range(0 0.4))
> ;
{res}{txt}
{com}. #delimit cr     
{txt}delimiter now cr
{com}. 
. graph save       FigR1_histo_sw_localbin11.gph, replace
{res}{txt}file {bf:FigR1_histo_sw_localbin11.gph} saved

{com}. graph export FigR1_histo_sw_localbin11.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_sw_localbin11.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigR1_histo_sw_localbin11.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_sw_localbin11.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
.                 ** 2014 **
. 
. #delimit;
{txt}delimiter now ;
{com}. graph twoway histogram eei_bin if year == 2014 & eei_bin < 68 & eei_bin > 53 [fw=unit_weight], 
> start(53.5)width(0.4) fraction xline(58.7) fcolor(dkgreen) lcolor(black%70) lwidth(vthin) xtitle("") 
> ytitle("Percent of Sales") legend(off) graphregion(color(white)) plotregion(lcolor(black))
> ylabel(0(0.1)0.4, labsize(small)) xlabel(54(2)68, labsize(small)) yscale(range(0 0.4))
> ;
{res}{txt}
{com}. #delimit cr     
{txt}delimiter now cr
{com}. 
. graph save       FigR1_histo_sw_localbin14.gph, replace
{res}{txt}file {bf:FigR1_histo_sw_localbin14.gph} saved

{com}. graph export FigR1_histo_sw_localbin14.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_sw_localbin14.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigR1_histo_sw_localbin14.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_sw_localbin14.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
.         *** unweighted ***
.         
.                 ** 2011 ** 
. #delimit;
{txt}delimiter now ;
{com}. graph twoway histogram eei_bin if year == 2011 & eei_bin < 68 & eei_bin > 53 [fw=product_count_bin], 
> start(53.5)width(0.4) fraction xline(58.7) fcolor(ebg) lcolor(black%70) lwidth(vthin) xtitle("") 
> ytitle("Percent of Sales") legend(off) graphregion(color(white)) plotregion(lcolor(black))
> ylabel(0(0.1)0.4, labsize(small)) xlabel(54(2)68, labsize(small)) yscale(range(0 0.4))
> ;
{res}{txt}
{com}. #delimit cr     
{txt}delimiter now cr
{com}. 
. graph save       FigR1_histo_nw_localbin11.gph, replace
{res}{txt}file {bf:FigR1_histo_nw_localbin11.gph} saved

{com}. graph export FigR1_histo_nw_localbin11.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_nw_localbin11.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigR1_histo_nw_localbin11.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_nw_localbin11.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
.                 ** 2014 **
. 
. #delimit;
{txt}delimiter now ;
{com}. graph twoway histogram eei_bin if year == 2014 & eei_bin < 68 & eei_bin > 53 [fw=product_count_bin], 
> start(53.5)width(0.4) fraction xline(58.7) fcolor(dkgreen) lcolor(black%70) lwidth(vthin) xtitle("") 
> ytitle("Percent of Sales") legend(off) graphregion(color(white)) plotregion(lcolor(black))
> ylabel(0(0.1)0.4, labsize(small)) xlabel(54(2)68, labsize(small)) yscale(range(0 0.4))
> ;
{res}{txt}
{com}. #delimit cr     
{txt}delimiter now cr
{com}. 
. graph save       FigR1_histo_nw_localbin14.gph, replace
{res}{txt}file {bf:FigR1_histo_nw_localbin14.gph} saved

{com}. graph export FigR1_histo_nw_localbin14.eps, as(eps) fontface("Baskerville Old Face") replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_nw_localbin14.eps{rm}
saved as
EPS
format
{p_end}

{com}. graph export FigR1_histo_nw_localbin14.png, as(png) width(1500) replace
{txt}{p 0 4 2}
file {bf}
FigR1_histo_nw_localbin14.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. log close 
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}R:\WSV2\TBu_AKe\Bunching_NEW\descriptives_1502.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}15 Mar 2023, 15:55:29
{txt}{.-}
{smcl}
{txt}{sf}{ul off}